package Demo04;

abstract class animal{
    public String name;

    public animal(String name){
        this.name=name;
    }
}

interface Irunning{
    void run();
}

interface Iswimming{
    void swim();
}

interface Ifly{
    void fly();
}

class dog extends animal implements Irunning{
    public dog(String name){
        super(name);
    }

    @Override
    public void run(){
        System.out.println(name +" 正在用四条狗腿跑！");
    }
}

class Fish extends animal implements Iswimming{

    public Fish(String name) {
        super(name);
    }

    @Override
    public void swim() {
        System.out.println(name + "正在游泳！");
    }
}
class Bird extends animal implements Ifly {

    public Bird(String name) {
        super(name);
    }

    @Override
    public void fly() {
        System.out.println(name + "正在飞！");
    }
}
class Duck extends animal implements Irunning,Ifly,Iswimming {

    public Duck(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(name + "正在用两条腿跑！");
    }

    @Override
    public void swim() {
        System.out.println(name + "正在用两条腿在游泳！");
    }

    @Override
    public void fly() {
        System.out.println(name + "正在用翅膀飞！");
    }
}

class Robot implements Irunning{

    @Override
    public void run() {
        System.out.println("机器人在用机器腿跑步！");
    }
}

public class test1 {
    //只要实现了 IRunning 接口的 都可以接收
    public static void walk(Irunning run){
        run.run();
    }

    public static void swim(Iswimming swim){
        swim.swim();
    }

    public static void func(animal a){

    }

    public static void main(String[] args) {
        walk(new dog("二哈"));
        walk(new Duck("唐老鸭"));
        walk(new Robot());
        System.out.println("--------------------");

        swim(new Fish("鲤鱼"));
        swim(new Duck("唐老鸭1"));

    }

}


